import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:znmm/UI/A_Common/buttons/easy_button/easy_elevated_button.dart';
import 'package:znmm/UI/A_Common/custom_textField.dart';
import 'package:znmm/UI/utils/my_global.dart';
import 'package:znmm/config/app_color.dart';

import 'mag/login_mag.dart';

class RegisterPage extends StatefulWidget {
  const RegisterPage({super.key});

  @override
  State<RegisterPage> createState() => _RegisterPageState();
}

class _RegisterPageState extends State<RegisterPage> {
  String _userName = "";
  String _email = "";
  String _pwd1 = "";
  String _pwd2 = "";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColor.backgroundColor,
      appBar: MyGlobal.getNavigationBar(context, "Register"),
      body: SingleChildScrollView(
          child: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            SizedBox(
              height: 15.h,
            ),
            CustomTextField(
              labelText: 'UserName',
              strText: _userName,
              onInputComplete: (value) {
                //print("用户名:$value");
                _userName = value;
              },
            ),
            const SizedBox(height: 16.0),
            CustomTextField(
              labelText: 'Email',
              strText: _email,
              icon: Icons.email,
              onInputComplete: (value) {
                //print("邮箱:$value");
                _email = value;
              },
            ),
            const SizedBox(height: 16.0),
            CustomTextField(
              labelText: 'Password',
              strText: _pwd1,
              icon: Icons.lock,
              bHasHidIcon: true,
              onInputComplete: (value) {
                //print("密码:$value");
                _pwd1 = value;
              },
            ),
            const SizedBox(height: 16.0),
            CustomTextField(
              labelText: 'Confirm Password',
              strText: _pwd2,
              icon: Icons.lock,
              bHasHidIcon: true,
              onInputComplete: (value) {
                //("确认密码:$value");
                _pwd2 = value;
              },
            ),
            SizedBox(height: 64.0.h),
            EasyElevatedButton(
              isRounded: true,
              width: double.infinity,
              height: 44,
              label: 'Register',
              color: Colors.black,
              onPressed: () {
                LoginMag().reqRegister(
                  _userName,
                  _email,
                  _pwd1,
                  _pwd2,
                  callback: (p0) {
                    Get.back();
                  },
                );
              },
            ),
          ],
        ),
      )),
    );
  }
}


/*

{
  id: 23,
  date_created: 2024-12-27T11: 38: 32,
  date_created_gmt: 2024-12-27T03: 38: 32,
  date_modified: 2024-12-27T11: 38: 32,
  date_modified_gmt: 2024-12-27T03: 38: 32,
  email: 157@qq.com,
  first_name: ,
  last_name: ,
  role: customer,
  username: 157,
  billing: {
    first_name: ,
    last_name: ,
    company: ,
    address_1: ,
    address_2: ,
    city: ,
    postcode: ,
    country: ,
    state: ,
    email: ,
    phone: 
  },
  shipping: {
    first_name: ,
    last_name: ,
    company: ,
    address_1: ,
    address_2: ,
    city: ,
    postcode: ,
    country: ,
    state: ,
    phone: 
  },
  is_paying_customer: false,
  avatar_url: https: //secure.gravatar.com/avatar/9b5a2aaa061addded71dce1e34430754?s=96&d=mm&r=g,
  meta_data: [
    
  ],
  _links: {
    self: [
      {
        href: https: //react.glassesin.com/wp-json/wc/v3/customers/23,
        targetHints: {
          allow: [
            GET,
            POST,
            PUT,
            PATCH,
            DELETE
          ]
        }
      }
    ],
    collection: [
      {
        href: https: //react.glassesin.com/wp-json/wc/v3/customers
      }
    ]
  }
}

*/